package controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import entity.Category;
import service.CategoryService;

@Controller
@RequestMapping("/category")
public class CategoryController {

	@Autowired
	private CategoryService categoryService;
	
	@RequestMapping("list.jsp")
	public String list(HttpServletRequest request){
		List<Category> list=categoryService.findAll();
		request.setAttribute("list", list);
		return "list";
	}
	@RequestMapping(name="add.jsp",method=RequestMethod.GET)
	public String addPage(HttpServletRequest request){
		return "add";
	}
	@RequestMapping(name="add.jsp",method=RequestMethod.POST)
	public String add(HttpServletRequest request){
		return "redirect:list.jsp";
	}
}
